<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <div></div>
    <div></div>
    <div></div>

    <script>

        const oDivs = document.querySelectorAll('div');

        // 
        const arr = Array.prototype.slice.call(oDivs);
        console.log(arr);

        const arr2 = [].slice.apply(oDivs);
        console.log(arr2);


        // const arr = [1, 2, 3];

        // const arr2 = arr.slice();
        // console.log(arr2)



        const obj = {
            a: 'hi',
            fn: function () {
                console.log(this);
                const arr = [1, 2, 3];
                // forEach(cb)    cb是一个回调函数，只是声明了这个函数，并没有调用
                // bind 只是改变this指向
                arr.forEach(function (v, i) {
                    console.log(this.a + v);
                }.bind(obj))
            }
        }


        obj.fn()

    </script>

</body>

</html>